import { ApiProperty } from '@nestjs/swagger';
import { IsNotEmpty, IsString } from 'class-validator';
import { Status } from 'src/constants';
import { HttpResponse } from 'src/share';

export class LoginRequestBody {
  @IsNotEmpty()
  @IsString()
  @ApiProperty({
    required: true,
  })
  username: string;

  @IsNotEmpty()
  @IsString()
  @ApiProperty({
    required: true,
  })
  password: string;
}

export class LoginResponse extends HttpResponse {
  data: {
    token: string;
  };
  constructor(token: string) {
    super('ok', Status.SUCCESS);
    this.data = {
      token,
    };
  }
}

export class LoginResFailure extends HttpResponse {
  constructor() {
    super('用户不存在', Status.LOGIN_FAIL_FOR_NOTEXIST);
  }
}
